home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Cookie / id-tracker.izs < prev    next >
Text File  |  2005-09-28  |  5KB  |  187 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>ID Tracker
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>Allows use to save a visitor's referral ID in a cookie ID on their computer. Then, you can you can access that ID cookie from the rest of your site. IS a helpful script for big sites that may include things like members areas!<!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>cookies<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13. <!-- HOW TO INSTALL ID TRACKER:
  14.  
  15.   1.  Copy code into the HEAD section of document
  16.   2.  Add the onLoad event handler into the BODY tag
  17.   3.  Put last coding into the BODY section of document  -->
  18.  
  19. <!-- STEP ONE: Add code into HEAD section of document  -->
  20.  
  21. <HEAD>
  22.  
  23. <SCRIPT LANGUAGE="JavaScript">
  24. <!-- Original:  Ronnie T. Moore -->
  25. <!-- Web Site:  Evrsoft -->
  26.  
  27.  
  28.  
  29. <!-- Begin
  30. function readID() {
  31. var expDays = 365; // number of days the cookie should last
  32. var expDate = new Date();
  33. expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
  34. var id = GetCookie('id');
  35. if (id == null || id == "no id") {
  36. if (location.search.length > 1) id = location.search.substring(1, location.search.length);
  37. else id = "no id";
  38. if (id != GetCookie('id')) SetCookie('id', id, expDate);
  39. }
  40.  
  41. // You can change the FORM location below
  42. // where the referral ID is stored on your page
  43. // You then access this element to get the ID
  44. document.idform.id.value = id;
  45.  
  46. }
  47. function getCookieVal (offset) {  
  48. var endstr = document.cookie.indexOf (";", offset);  
  49. if (endstr == -1)    
  50. endstr = document.cookie.length;  
  51. return unescape(document.cookie.substring(offset, endstr));
  52. }
  53. function GetCookie (name) {  
  54. var arg = name + "=";  
  55. var alen = arg.length;  
  56. var clen = document.cookie.length;  
  57. var i = 0;  
  58. while (i < clen) {    
  59. var j = i + alen;    
  60. if (document.cookie.substring(i, j) == arg)      
  61. return getCookieVal (j);    
  62. i = document.cookie.indexOf(" ", i) + 1;    
  63. if (i == 0) break;   
  64. }  
  65. return null;
  66. }
  67. function SetCookie (name, value) {  
  68. var argv = SetCookie.arguments;  
  69. var argc = SetCookie.arguments.length;  
  70. var expires = (argc > 2) ? argv[2] : null;  
  71. var path = (argc > 3) ? argv[3] : null;  
  72. var domain = (argc > 4) ? argv[4] : null;  
  73. var secure = (argc > 5) ? argv[5] : false;  
  74. document.cookie = name + "=" + escape (value) + 
  75. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  76. ((path == null) ? "" : ("; path=" + path)) +  
  77. ((domain == null) ? "" : ("; domain=" + domain)) +    
  78. ((secure == true) ? "; secure" : "");
  79. }
  80. //  End -->
  81. </script>
  82. </HEAD>
  83.  
  84. <!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->
  85.  
  86. <BODY OnLoad="readID()">
  87.  
  88. <!-- STEP THREE: Copy code into BODY section of document  -->
  89.  
  90. <form name=idform>
  91. <input type=hidden name=id>
  92. </form>
  93.  
  94. <!-- END OF SCRIPT -->
  95. <!/SCRIPT>
  96.  
  97. <!PREVIEW>
  98. <!-- START OF SCRIPT -->
  99.  
  100.  
  101. <!-- HOW TO INSTALL ID TRACKER:
  102.  
  103.   1.  Copy code into the HEAD section of document
  104.   2.  Add the onLoad event handler into the BODY tag
  105.   3.  Put last coding into the BODY section of document  -->
  106.  
  107. <!-- STEP ONE: Add code into HEAD section of document  -->
  108.  
  109. <HEAD>
  110.  
  111. <SCRIPT LANGUAGE="JavaScript">
  112. <!-- Original:  Ronnie T. Moore -->
  113. <!-- Web Site:  Evrsoft -->
  114.  
  115.  
  116.  
  117. <!-- Begin
  118. function readID() {
  119. var expDays = 365; // number of days the cookie should last
  120. var expDate = new Date();
  121. expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
  122. var id = GetCookie('id');
  123. if (id == null || id == "no id") {
  124. if (location.search.length > 1) id = location.search.substring(1, location.search.length);
  125. else id = "no id";
  126. if (id != GetCookie('id')) SetCookie('id', id, expDate);
  127. }
  128.  
  129. // You can change the FORM location below
  130. // where the referral ID is stored on your page
  131. // You then access this element to get the ID
  132. document.idform.id.value = id;
  133.  
  134. }
  135. function getCookieVal (offset) {  
  136. var endstr = document.cookie.indexOf (";", offset);  
  137. if (endstr == -1)    
  138. endstr = document.cookie.length;  
  139. return unescape(document.cookie.substring(offset, endstr));
  140. }
  141. function GetCookie (name) {  
  142. var arg = name + "=";  
  143. var alen = arg.length;  
  144. var clen = document.cookie.length;  
  145. var i = 0;  
  146. while (i < clen) {    
  147. var j = i + alen;    
  148. if (document.cookie.substring(i, j) == arg)      
  149. return getCookieVal (j);    
  150. i = document.cookie.indexOf(" ", i) + 1;    
  151. if (i == 0) break;   
  152. }  
  153. return null;
  154. }
  155. function SetCookie (name, value) {  
  156. var argv = SetCookie.arguments;  
  157. var argc = SetCookie.arguments.length;  
  158. var expires = (argc > 2) ? argv[2] : null;  
  159. var path = (argc > 3) ? argv[3] : null;  
  160. var domain = (argc > 4) ? argv[4] : null;  
  161. var secure = (argc > 5) ? argv[5] : false;  
  162. document.cookie = name + "=" + escape (value) + 
  163. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  164. ((path == null) ? "" : ("; path=" + path)) +  
  165. ((domain == null) ? "" : ("; domain=" + domain)) +    
  166. ((secure == true) ? "; secure" : "");
  167. }
  168. //  End -->
  169. </script>
  170. </HEAD>
  171.  
  172. <!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->
  173.  
  174. <BODY OnLoad="readID()">
  175.  
  176. <!-- STEP THREE: Copy code into BODY section of document  -->
  177.  
  178. <form name=idform>
  179. <input type=hidden name=id>
  180. </form>
  181.  
  182.  
  183. <!-- END OF SCRIPT -->
  184. <!/PREVIEW>
  185.  
  186. <!RELATED>NONE<!/RELATED>
  187.